﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="验证控件.aspx.cs" Inherits="计科201518彭康.验证控件" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script>
        function shu(source, arges)
        {
            if ((arges.Value % 2) == 0)
                arges.IsValid = true;
            else
                arges.IsValid = false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
        <asp:Label ID="Label1" runat="server" Text="用户名："></asp:Label>
        <asp:TextBox ID="用户名验证" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="用户名验证" ErrorMessage="用户名不能为空！" ForeColor="Red"></asp:RequiredFieldValidator>
        <p>
            <asp:Label ID="Label2" runat="server" Text="姓名："></asp:Label>
            <asp:TextBox ID="姓名验证" runat="server"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="姓名验证" ErrorMessage="请输入2-4个汉字" ForeColor="Red" ValidationExpression="[\u4E00-\u9FA5]{2,4}"></asp:RegularExpressionValidator>
        </p>
        <asp:Label ID="Label3" runat="server" Text="国籍："></asp:Label>
        <asp:DropDownList ID="国籍验证" runat="server">
            <asp:ListItem></asp:ListItem>
            <asp:ListItem>中国</asp:ListItem>
            <asp:ListItem>美国</asp:ListItem>
            <asp:ListItem>英国</asp:ListItem>
            <asp:ListItem>法国</asp:ListItem>
            <asp:ListItem>日本</asp:ListItem>
        </asp:DropDownList>
&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="国籍验证" ErrorMessage="国籍必须选择" ForeColor="Red"></asp:RequiredFieldValidator>
        <p>
            <asp:Label ID="Label4" runat="server" Text="密码："></asp:Label>
            <asp:TextBox ID="密码验证" runat="server" TextMode="Password"></asp:TextBox>
        </p>
        <asp:Label ID="Label5" runat="server" Text="确认密码："></asp:Label>
        <asp:TextBox ID="确认密码验证" runat="server" TextMode="Password"></asp:TextBox>
        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="密码验证" ControlToValidate="确认密码验证" ErrorMessage="两次输入密码不一致" ForeColor="Red"></asp:CompareValidator>
        <p>
            <asp:Label ID="Label6" runat="server" Text="年龄："></asp:Label>
            <asp:TextBox ID="年龄验证" runat="server"></asp:TextBox>
            <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="年龄验证" ErrorMessage="年龄必须在0-120之间" ForeColor="Red" MaximumValue="120" MinimumValue="0" Type="Integer"></asp:RangeValidator>
        </p>
        <p>
        <asp:Label ID="Label10" runat="server" Text="邮箱："></asp:Label>
            <asp:TextBox ID="邮箱验证" runat="server"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" ErrorMessage="邮箱格式不对！" ControlToValidate="邮箱验证" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        </p>
        <p>
            <asp:Label ID="Label11" runat="server" Text="偶数："></asp:Label>
            <asp:TextBox ID="偶数验证" runat="server"></asp:TextBox>
            <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="偶数验证" ErrorMessage="不是偶数" ClientValidationFunction="shu" ForeColor="Red"></asp:CustomValidator>
        </p>
        <p>
        <asp:Label ID="Label7" runat="server" Text="出生日期："></asp:Label>
        <asp:TextBox ID="出生日期验证" runat="server"></asp:TextBox>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="出生日期验证" ErrorMessage="生日输入格式不正确！" ForeColor="Red" ValidationExpression="\d{4}(\-|\/|.)\d{1,2}\1\d{1,2}"></asp:RegularExpressionValidator>
        </p>
        <p>   <asp:Label ID="Label8" runat="server" Text="身份证号："></asp:Label>
            <asp:TextBox ID="身份证验证" runat="server"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="身份证验证" ErrorMessage="身份证输入格式不对！" ForeColor="Red" ValidationExpression="\d{17}[\d|X]|\d{15}"></asp:RegularExpressionValidator>
        </p>
        <asp:Label ID="Label9" runat="server" Text="个人简介："></asp:Label>
        <p>
            <asp:TextBox ID="个人简介验证" runat="server" TextMode="MultiLine" Height="79px" Width="263px"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ControlToValidate="个人简介验证" ErrorMessage="不少于10个字" ForeColor="Red" ValidationExpression="[\u4E00-\u9FA5]{10,100}"></asp:RegularExpressionValidator>
        </p>
        <p>
            <asp:Button ID="Button1" runat="server" Text="注册" OnClick="Button1_Click" />&nbsp;
            <asp:Button ID="Button2" runat="server" CausesValidation="False" OnClick="Button2_Click" Text="返回登录" />
        </p>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" ShowMessageBox="True" />
    </form>
</body>
</html>
